package com.aiit.controller.admin;

import com.aiit.dto.BookingDTO;
import com.aiit.result.Result;
import com.aiit.service.BookingService;
import com.aiit.vo.BookingVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//预定接口
@RestController
@RequestMapping("/admin/booking")
@Api(tags = "预定接口")
@Slf4j
public class BookingController {

    @Autowired
    private BookingService bookingService;

    /**
     * 预定查询
     *
     * @param
     * @return
     */
    @GetMapping("/select")
    @ApiOperation("预定查询")
    public Result booking(@RequestParam("date") String date) {
        log.info("日期查询, 参数为：{}", date);
        try {
            //  BookingDTO bookingDTO = new BookingDTO();
            //  bookingDTO.setDate(date); // 假设 BookingDTO 有一个 setDate 方法
            BookingVO bookings = bookingService.select(date);
            return Result.success(bookings);
        } catch (Exception e) {
            log.error("查询预定信息时发生错误", e);
            return Result.error("查询预定信息时发生错误");
        }
    }

    @PutMapping("/update")
    @ApiOperation("编辑订座的信息")
    public Result Update(@RequestBody BookingDTO bookingDTO) {
        log.info("编辑订单信息:{}", bookingDTO);
        bookingService.update(bookingDTO);
        return Result.success();
    }


}


